package com.ousi.wx.service.Impl;

import cn.hutool.core.map.MapUtil;
import com.ousi.wx.dao.LotusPictureDao;
import com.ousi.wx.service.LotusPictureService;
import com.ousi.wx.util.PageUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.Map;

@Service
public class LotusPictureServiceImpl implements LotusPictureService {

    @Autowired
    private LotusPictureDao lotusPictureDao;

    @Override
    public PageUtils selectConditionByPage(Map map) {
        ArrayList<HashMap> list = null;
        long count = lotusPictureDao.selectCount();
        if (count != 0) {
            list = lotusPictureDao.selectConditionByPage(map);
        }else {
            list = new ArrayList<>();
        }
        int page = MapUtil.getInt(map, "page");
        Integer length = MapUtil.getInt(map, "length");
        PageUtils pageUtils = new PageUtils(list, count, page, length);
        return pageUtils;
    }
}
